﻿#include "getclockeventdialog.h"
#include "ui_getclockeventdialog.h"
#include <QDebug>
GetClockEventDialog::GetClockEventDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GetClockEventDialog)
{
    ui->setupUi(this);
}

GetClockEventDialog::~GetClockEventDialog()
{
    delete ui;
}

Clock GetClockEventDialog::getClock(Clock &former)
{
    GetClockEventDialog dialog;
    dialog.ui->lineEdit_name->setText(former.getName());
    dialog.ui->textEdit_desc->setText(former.getDescription());
    dialog.ui->timeEdit->setTime(former.getTime());
    dialog.exec();
    return dialog.event;
}

Clock GetClockEventDialog::getClock()
{
    GetClockEventDialog dialog;
    Clock event;
    return dialog.getClock(event);
}

void GetClockEventDialog::on_pushButton_cencel_clicked()
{
    this->event.setName("");
    close();
}

void GetClockEventDialog::on_pushButton_save_clicked()
{
    this->event.setName(ui->lineEdit_name->text());
    this->event.setDescription(ui->textEdit_desc->toPlainText());
    QTime time = ui->timeEdit->time();
    this->event.setTime(time);
    close();
}

void GetClockEventDialog::on_radioButton_once_clicked(bool checked)
{


}

void GetClockEventDialog::on_checkBox_mon_clicked(bool checked)
{

}


void GetClockEventDialog::on_checkBox_once_clicked(bool checked)
{
    if(checked)this->event.addRepeat(ONCE);
    else this->event.deleteRepeat(ONCE);

}

void GetClockEventDialog::on_checkBox_tue_clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox_wed_clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox__clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox_fri_clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox_sat_clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox_sun_clicked(bool checked)
{

}

void GetClockEventDialog::on_checkBox_once_toggled(bool checked)
{
    if(checked){
        this->event.addRepeat(ONCE);
        ui->checkBox_->setEnabled(false);
        ui->checkBox_mon->setEnabled(false);
        ui->checkBox_tue->setEnabled(false);
        ui->checkBox_wed->setEnabled(false);
        ui->checkBox_fri->setEnabled(false);
        ui->checkBox_sat->setEnabled(false);
        ui->checkBox_sun->setEnabled(false);
        qDebug()<<this->event.getRepeat();
    }else{
        this->event.deleteRepeat(ONCE);
        ui->checkBox_->setEnabled(true);
        ui->checkBox_mon->setEnabled(true);
        ui->checkBox_tue->setEnabled(true);
        ui->checkBox_wed->setEnabled(true);
        ui->checkBox_fri->setEnabled(true);
        ui->checkBox_sat->setEnabled(true);
        ui->checkBox_sun->setEnabled(true);
    }
}

void GetClockEventDialog::on_checkBox_mon_toggled(bool checked)
{
    if(checked)this->event.addRepeat(MON);
    else this->event.deleteRepeat(MON);
}

void GetClockEventDialog::on_checkBox_tue_toggled(bool checked)
{
    if(checked)this->event.addRepeat(TUE);
    else this->event.deleteRepeat(TUE);
}

void GetClockEventDialog::on_checkBox_wed_toggled(bool checked)
{
    if(checked)this->event.addRepeat(WED);
    else this->event.deleteRepeat(WED);
}

void GetClockEventDialog::on_checkBox__toggled(bool checked)
{
    if(checked)this->event.addRepeat(THU);
    else this->event.deleteRepeat(THU);
}

void GetClockEventDialog::on_checkBox_fri_toggled(bool checked)
{
    if(checked)this->event.addRepeat(FRI);
    else this->event.deleteRepeat(FRI);
}

void GetClockEventDialog::on_checkBox_sat_toggled(bool checked)
{
    if(checked)this->event.addRepeat(SAT);
    else this->event.deleteRepeat(SAT);
}

void GetClockEventDialog::on_checkBox_sun_toggled(bool checked)
{
    if(checked)this->event.addRepeat(SUN);
    else this->event.deleteRepeat(SUN);
}
